<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>核心语法</title>
</head>
<body>
    <script>
        //人名的最后一个字母改为小写
        let str = "JACK|TOM|MIKE|PETER|JIM";
        let arr = str.split("|");
        console.log(arr);
        // for(let i in arr){
        //     let name = arr[i].substring(0,arr[i].length-1) +
        //          arr[i].substring(arr[i].length-1).toLowerCase();
        //     console.log(name);
        //     arr[i] = name;
        // }

        let arr2 = [];
        for(let item of arr){
            let name = item.substring(0,item.length-1) +
                 item.substring(item.length-1).toLowerCase();
            console.log(name)
            arr2.push(name);
        }
         let str2 = arr2.join("|");
        console.log(str2);
    </script>
</body>
</html>